<?php
/*
 * Tạo Support Product widget
* */
class Widget_footers extends WP_Widget
{
	
	//Khởi tạo contructor của 1 lớp
	function Widget_footers()
	{
		parent::WP_Widget('Widget_footers_Widget',
				esc_attr(__('Hiển thị footer html',THMENAME)),
				array('description' => esc_attr(__('Hiển thị footer html cột 1,cột 2,cột 3,cột 4.',THEMENAME))));

	}

	function widget( $args, $instance ) // hien thi noi dung widget
	{
		global $currency;
		extract($args);
		$title = apply_filters( 'widget_title',
				empty($instance['title']) ? '' : $instance['title'],
				$instance, $this->id_base);

		$showhtml = apply_filters( 'widget_text',
				$instance['showhtml'], $instance );

		?>
		<?php if($title):?>
		 <h4><?php echo $title;?></h4>
		 <?php endif;?>
         <ul>
         	  <?php 
         	  if($showhtml):
         	  	echo $showhtml;
         	  endif;
         	  ?>
          </ul>				
		<?php		
	}

	function update( $new_instance, $old_instance ) 
	{
		$instance = $old_instance;
				
		$instance['title'] = strip_tags($new_instance['title']);
		$instance['showhtml'] = $new_instance['showhtml'];		
		
		return $instance;
	}

	function form( $instance ) 
	{
		$instance = wp_parse_args( (array) $instance, 
			array( 'title' => '','showhtml' => '' ) );
		$title = strip_tags($instance['title']);
		$showhtml = $instance['showhtml'];		
		?>
		<p>
			<label for="<?php echo $this->get_field_id('title'); ?>">
				<?php echo  __('Tiêu đề:'); ?> </label>
			<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" 
				name="<?php echo $this->get_field_name('title'); ?>" type="text" 
				value="<?php if($title) echo  esc_attr($title);?>" />
		</p>
	
		<p>
			<label for="<?php echo $this->get_field_id('showhtml'); ?>">
				<?php _e('Nội dung:'); ?> </label><br/>
			<?php 
			$df = '                   
                      <li><a href="http://www.thietkexaydungvn.com/tieu-chi.htm">Tiêu chí</a></li>
                      <li><a href="http://www.thietkexaydungvn.com/linh-vuc-hoat-dong.htm">Lĩnh vực hoạt động</a></li>
                      <li><a href="http://www.thietkexaydungvn.com/qua-trinh-hinh-thanh.htm">Quá trình hình thành</a></li>         		
 			';
			?>	
			<textarea style="width: 100%; height: 180px;" name="<?php echo $this->get_field_name('showhtml'); ?>" id="<?php echo $this->get_field_name('showhtml'); ?>" rows="" cols=""><?php if($showhtml) echo  esc_attr($showhtml); else echo $df;?></textarea>
		</p>		
		<?php
	}
}
// End Support Product widget

register_widget('Widget_footers');

//===========================================================================================================================


// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++